package com.cmic.rcs.emoji.config;

import com.cmic.rcs.emoji.interceptor.SessionInterceptor;
import com.cmic.rcs.emoji.interceptor.TokenInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Slf4j
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;
    @Autowired
    private SessionInterceptor sessionInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册Token拦截器
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/api/app/**");
        log.info("WebConfig初始化完成，TokenInterceptor已注册，拦截路径: /api/app/**");

        // 注册Session拦截器
        registry.addInterceptor(sessionInterceptor)
                .addPathPatterns("/api/web/**");
        log.info("WebConfig初始化完成，SessionInterceptor已注册，拦截路径: /api/web/**");
    }
}
